package com.xjrsoft.module.app.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.xjrsoft.common.page.ConventPage;
import com.xjrsoft.common.page.PageInput;
import com.xjrsoft.common.page.PageOutput;
import com.xjrsoft.core.tool.utils.StringUtil;
import com.xjrsoft.module.app.dto.AppFnSchemeDto;
import com.xjrsoft.module.app.dto.AppFnSchemeListDto;
import com.xjrsoft.module.app.entity.XjrAppFnScheme;
import com.xjrsoft.module.app.mapper.XjrAppFnSchemeMapper;
import com.xjrsoft.module.app.service.IXjrAppFnSchemeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xjrsoft.module.app.vo.AppFnSchemeListVo;
import com.xjrsoft.module.app.vo.AppFnSchemeVo;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 自定义表单绑定APP设置信息表 服务实现类
 * </p>
 *
 * @author jobob
 * @since 2021-02-24
 */
@Service
public class XjrAppFnSchemeServiceImpl extends ServiceImpl<XjrAppFnSchemeMapper, XjrAppFnScheme> implements IXjrAppFnSchemeService {

    @Override
    public PageOutput<AppFnSchemeListVo> getPageList(AppFnSchemeListDto pageInput) {
        String keyword = pageInput.getKeyword();
        IPage<XjrAppFnScheme> page = ConventPage.getPage(pageInput);
        IPage<XjrAppFnScheme> pageList = this.page(page, Wrappers.<XjrAppFnScheme>query().lambda()
                .like(!StringUtil.isEmpty(keyword), XjrAppFnScheme::getName, keyword)
                .eq(!StringUtil.isEmpty(pageInput.getF_Type()), XjrAppFnScheme::getType, pageInput.getF_Type())
                .orderByDesc(XjrAppFnScheme::getCreateDate));
        return ConventPage.getPageOutput(pageList, AppFnSchemeListVo.class);
    }
}
